package leetcode;

import java.util.Arrays;

class Solution {
    public int[] bubble_sort(int[] nums) {
        int[] arr = Arrays.copyOf(nums, nums.length);
        for (int i = 0; i < arr.length - 1; i++) {
            boolean flag = true;
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    int tmp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = tmp;
                    flag = false;
                }
            }
            if (flag) {
                break;
            }
        }
        return arr;
    }
}

public class Test4 {
    public static void main(String[] args) {

    }
}
